<template>
  <div class="big">
      <!-- 搜索分割线 -->

      <!-- 第一大框：搜索条件及按钮 -->
      <div class="two">
        <el-form ref="queryForm" :model="queryParams" :inline="true" v-show="showSearch"   >
          <!-- 第一大框：搜索条件
           v-model="queryParams.handBrand"     查询参数中的手牌号
           -->
          <div class="first-one">
            <el-form-item label="手牌号" prop="handBrand" label-width="68px">
              <el-input v-model="queryParams.handBrand"
                        placeholder="手牌号"
                        @keyup.enter.native="handleQuery"
                        style="width:100px; display: inline-block;"/>
            </el-form-item>

            <el-col :span="4"></el-col>

            <el-form-item label="原手牌" prop="originalHand" label-width="68px">
              <el-input v-model="queryParams.originalHand"
                        placeholder="原手牌"
                        @keyup.enter.native="handleQuery"
                        style="width:100px; display: inline-block;"/>
            </el-form-item>

            <el-col :span="4"></el-col>

            <el-form-item label="消费品种" prop="entryName" style="display: inline-block" label-width="81px">
              <el-input v-model="queryParams.entryName"
                        placeholder="消费品种"
                        @keyup.enter.native="handleQuery"
                        style="width:100px"/>
            </el-form-item>
          </div>
          <!-- 第一大框：按钮 -->
          <div class="first-two">
            <el-form-item>
              <el-button type="primary"  size="small" @click="handleQuery">搜索</el-button>
              <el-button type="primary" plain  size="small" @click="resetQuery">重置</el-button>
              <el-button   size="small" @click="close">返回</el-button>
            </el-form-item>
          </div>
        </el-form>
      </div>
      <!-- 第二大框：表格
      v-loading="loading"  加载
      :data="tableData"   数据表名
      :header-cell-style="{textAlign:'center',fontSize:'13px',background:'#eef1f6',color:'#606266'}"  表头样式
      :cell-style="{textAlign: 'center'}"  表内样式
      -->
      <div class="three">
        <el-table
          v-loading="loading"
          :data="tableData"
          :header-cell-style="{textAlign:'center',fontSize:'14px',background:'#eef1f6',color:'#606266'}"
          :cell-style="{textAlign: 'center'}"
          height="400"
          border
          style="width: 100% ">
          <el-table-column
            prop="originalHand"
            label="原手牌"
            width="100">
          </el-table-column>
          <el-table-column
            prop="handBrand"
            label="手牌号"
            width="100">
          </el-table-column>
          <el-table-column
            prop="entryName"
            label="品名"
            width="200">
          </el-table-column>
          <el-table-column
            prop="unit"
            label="单位"
            width="100">
          </el-table-column>
          <el-table-column

            prop="quantity"
            label="数量"
            width="100">
          </el-table-column>
          <el-table-column
            prop="unitPrice"
            label="单价"
            width="100">
          </el-table-column>
          <el-table-column
            prop="totalAmount"
            label="金额"
            width="120">
            <template slot-scope="scope">
              {{(scope.row.sum = scope.row.unitPrice *scope.row.quantity)| keepTwoNum}}
            </template>
          </el-table-column>
          <el-table-column
            prop="nickName"
            label="服务员"
            width="120">
          </el-table-column>
          <el-table-column
            prop="recordingTime"
            label="录单时间"
            width="250">
          </el-table-column>
          <el-table-column
            prop="sailingsSigns"
            label="班次标志"
            width="120">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.yqg_sailings_signs" :value="scope.row.sailingsSigns"/>
            </template>
          </el-table-column>
        </el-table>
      </div>

  </div>
</template>


<script>
import {chaxun} from "@/api/module/lyx/chaxun";
import project from "../../../project/project";          //调用@/api/module/lyx/chaxun中的chaxun功能

export default {
  filters:{
    keepTwoNum(value){
      value=Number(value);
      return value.toFixed(2)
    }
  },
  name: "chaxun",
  dicts: ['yqg_consumption_details','yqg_sailings_signs'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      tableData: [],
      baseinfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        userId: null,
        deptId: null,
        department: null,
        nickName: null,
        userName: null,
        post: null,
        originalHand: null,
        handBrand: null,
        handCategory: null,
        handState: '1',
        retentionStatus: null,
        mergeStatus: null,
        openingTime: null,
        drawTime: null,
        mergeHands: null,
        mergeBarBillsId: null,
        handoverStatus: '1',
        leaveTime: null,
        beforeLeave: null,
        beforeBarBillsId: null,
        entryName: null,
        projectCategory: 22,
        projectCode: null,
        mnemonicCode: null,
        unit: null,
        unitPrice: null,
        commissionPrice: null,
        together: null,
        sailingsSigns: null,
        barBillsId: null,
        recordingTime: null,
        quantity: null,
        totalAmount: null,
        seat: null,
        orderNumber: null,
        paymentMethod: null,
        consumptionStatus: null,
        chargebackTime: null,
        reasonForChargeback: null,
        chargebackProcessorAccount: null,
        chargebackProcessorName: null,
        clockTime: null,
        nextClockTime: null,
        nextClockStatus: null,
        recordEmployeeNumber: null,
        recorderEmployeeName: null,
        roomType: null,
        openingHours: null,
        checkOutTime: null,
        checkOutStatus: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },

      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.queryParams.entryName="皮美";
    this.getList();
    this.queryParams.entryName="";
  },
  methods: {
    close() {
      // this.open = false;
      this.$emit("closeDialog")
      this.resetQuery();
    },
    /** 金额合计操作 */
    getSummaries(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '总价';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] += ' 元';
        } else {
          sums[index] = 'N/A';
        }
      });

      return sums;
    },

    /** 查询基本信息列表 */
    getList() {
      this.loading = true;
      chaxun(this.queryParams).then(response => {
        this.tableData = response.rows;  /*数据传送到tableData*/
        this.total = response.total;
        this.loading = false;
      });
    },

    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },

    // 表单重置，表格内显示的数据
    reset() {
      this.form = {
        handBrand: null,
        originalHand: null,
        entryName: "",
        unit: null,
        quantity: null,
        unitPrice: null,
        totalAmount: null,
        nickName: null,
        recordingTime: null,
        sailingsSigns: null,
        NOTE: null,
        NOTE1: null,
        NOTE2: null,
      };
      this.queryParams.entryName='';
      this.resetForm("form");
    },

    /** 搜索按钮操作 */
    handleQuery() {
      // this.queryParams.pageNum = 1;
      if(this.queryParams.entryName.includes("皮美")){
        this.getList();
      }
      else if(this.queryParams.entryName==""){
         console.log(this.queryParams.handBrand)
         this.queryParams.entryName="皮美";
         this.getList();
         this.queryParams.entryName="";
      }
      else{
        this.tableData=[];
      }
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.entryName="皮美";
      this.handleQuery();
      this.queryParams.entryName='';
    },

    /** 历史查询按钮操作 */
    handleSearch() {
      this.reset();
      this.open = true;
      this.title = "历史入单情况查询";
    },
  }
};
</script>
<style scoped>
/*大框样式*/
.big {
  display: flex;
  flex-direction: column;
  margin-left: 1%;
  margin-right: 1%;
  margin-top: 1%;
  margin-bottom: 1%;
}

/*搜索分割线样式*/
/* .one {
 display: flex;
  flex-direction: column;
  margin-right: 0px;
  margin-left: 0px;
  width: 100%;
} */
/*搜索条件及按钮样式*/
.two {
 /* margin-top: -1%; */
  margin-bottom: 5px;
  margin-left: 7px;
  height: 8%;
  width: 100%;
  display: flex;
  flex-direction: column;
}
/*搜索条件样式*/
.first-one {
  width: 80%;
  display: inline-block;
  margin-top: 1%;
  margin-left: -2%;
}
/*搜索按钮样式*/
.first-two {
  margin-top: 1%;
  float: right;
  display: inline-block;

}
/*表格部分样式*/
.three {
  height: 60%;
  width: 100%;
  display: inline-block;
}
/*弹框头部
  ::v-deep .el-dialog__header {
    --el-text-color-primary: #1EFFFF;
    --el-text-color-regular: #fff;
    padding: 0 !important;
    width: 100%;
    height: 40px;
    background: linear-gradient(90deg, #1165F8 0%, rgba(28, 97, 234, 0) 100%);
  }*/
/*弹框标题
  ::v-deep .el-dialog__title {
    margin-left: 8px;
    line-height: 40px;
    font-size: 20px;
    color: #FFFFFF;
    width: 100%;
  }*/
/*弹框内容部分
  ::v-deep .el-dialog__body {
    margin-top: -3%;
    margin-bottom: 7%;
  }*/
/*
滚动条宽度
/deep/ .el_table__body-wrapper::-webkit-scrollbar{
  width: 8px;横向滚动条
  height:8px;纵向滚动条
}
滚动条滑块
/deep/ .el_table__body-wrapper::-webkit-scrollbar-thumb{
background-color: #ddd;
border-radius: 3px;
}
*/
/*.el-dialog__header{*/
/*  width: 100%;*/
/*  height: 10%;*/
/*}*/
</style>
